package com.cyx;

import java.util.Scanner;

/**
 * @author 陈裕星
 * @version 1.0
 */
public class 最长回文子串之动态规划法 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] chars = str.toCharArray();
        int len = str.length();
        //状态:表示字符从i到j是否是回文
        boolean dp[][] = new boolean[len][len];
        for (int i = 0; i < len; i++){
            dp[i][i] = true;
        }

        int max = 1,start = 0;
        //状态转移
        for(int j = 1; j < len; j++){
            for(int i = 0; i < len-1 &&  i < j; i++){
                if(chars[i] != chars[j]){
                    dp[i][j] = false;
                }else {
                    if(j - i <= 2){
                        dp[i][j] = true;
                    }else{
                        dp[i][j] = dp[i+1][j-1];
                    }
                }
                if(max < j - i + 1 && dp[i][j]){
                    max = j - i + 1;
                    start = i;
                }
            }
        }
        System.out.println(str.substring(start,start + max));
    }
}
